package errorx

var message map[uint32]string

func init() {
	message = make(map[uint32]string)
	message[OK] = "SUCCESS"
	message[ServerCommonError] = "服务器开小差啦,稍后再来试一试"
	message[RequestParamError] = "参数错误"
	message[TokenExpireError] = "token失效,请重新登陆"
	message[TokenGenerateError] = "生成token失败"
	message[DbError] = "数据库繁忙,请稍后再试"
	message[DbUpdateAffectedZeroError] = "更新数据影响行数为0"

	message[UserNameError] = "该账号不存在"
	message[UserPasswordError] = "请确认账号或密码正确"
	message[UserExits] = "账号已经存在"
	message[UserInsertError] = "注册失败"
	message[UserIdUnknown] = "未知用户ID"
	message[UserMobileUnknown] = "未知用户号码"
	message[UserNameEmpty] = "用户名为空"
	message[UserMobileEmpty] = "手机号码为空"
	message[UserPasswordEmpty] = "密码为空"
	message[UserNotExits] = "用户不存在"
	message[VerificationEmpty] = "验证码为空"
	message[VerificationExpired] = "验证码过期"
	message[VerificationError] = "验证码错误"

	message[ArticleTitleEmpty] = "标题为空"
	message[ArticleContentEmpty] = "内容太少"
	message[ArticleCoverEmpty] = "封面为空"
	message[ArticleSortTypeInvalid] = "文章排序类型无效"
	message[ArticleIdUnknown] = "该文章不存在"

	message[WsConnectError] = "ws链接异常"

	message[FollowedUserIdEmpty] = "关注ID为空"
	message[CannotFollowSelf] = "不能关注自己"

}

func MapErrMsg(errCode uint32) string {
	if msg, ok := message[errCode]; ok {
		return msg
	} else {
		return "服务器开小差啦,稍后再来试一试"
	}
}

func IsCodeErr(errCode uint32) bool {
	if _, ok := message[errCode]; ok {
		return true
	} else {
		return false
	}
}
